home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / DU Folder / DataSave / Sources / Sources / DataSavePrt.cpp < prev    next >
Encoding:
Text File  |  1995-10-25  |  4.4 KB  |  171 lines  |  [TEXT/MPS ]

  1. //    Copyright © 1995 Apple Computer, Inc. All rights reserved.
  2. //    Release Version:    $ 1.0 d11 $
  3.  
  4. //================================================================================
  5. #ifndef DATASAVEPRT_H
  6. #include "DataSavePrt.h"        // CDataSavePart
  7. #endif
  8.  
  9. #ifndef _DATASAVEFRAME_
  10. #include "DataSaveFrm.h"        // CDataSaveFrame
  11. #endif
  12.  
  13. #ifndef PIZZA_H
  14. #include "Pizza.h"            //  CPizza
  15. #endif
  16.  
  17. #ifndef CONSTANT_H
  18. #include "Constant.h"        // my menu command numbers
  19. #endif
  20.  
  21. // --- DU Selection FW ---------------------
  22. #ifndef DUSELECTABLE_H
  23. #include "DUSelectable.h"    // DU_MSelectable
  24. #endif
  25.  
  26. #ifndef DULIST_H
  27. #include "DUList.h"            // DU_CList
  28. #endif
  29.  
  30. #ifndef DULISTSELECTION_H
  31. #include "DUListSelection.h"    // DU_CListSelection
  32. #endif
  33.  
  34. // ----- Framework Layer -----
  35. #ifndef FWPRESEN_H
  36. #include "FWPresen.h"        // FW_CPresentation
  37. #endif
  38.  
  39. #ifndef FWUTIL_H
  40. #include "FWUtil.h"            // FW_Beep()
  41. #endif
  42.  
  43. #ifndef FWMEMMGR_H
  44. #include "FWMemMgr.h"        // FW_CMemoryManager
  45. #endif
  46.  
  47. // ----- OS Layer -----
  48. #ifndef FWRESFIL_H
  49. #include "FWResFil.h"        // FW_CResourceFile
  50. #endif
  51.  
  52. #ifndef FWCFMRES_H
  53. #include "FWCFMRes.h"        // FW_CSharedLibraryResourceFile
  54. #endif
  55.  
  56. #ifndef FWEVENT_H
  57. #include "FWEvent.h"        // FW_CMenuEvent
  58. #endif
  59.  
  60. #ifndef FWSUSINK_H
  61. #include "FWSUSink.h"        // FW_CStorageUnitSink
  62. #endif
  63.  
  64. // ----- Foundation Layer -----
  65. #ifndef FWSTREAM_H
  66. #include <FWStream.h>        // FW_InitializeArchiving
  67. #endif
  68.  
  69. #ifndef FWSTRGAR_H
  70. #include "FWStrgAr.h"        // FW_CStringArchiver
  71. #endif
  72.  
  73. #ifndef FWMEMMGR_H
  74. #include "FWMemMgr.h"        // FW_CMemoryManager
  75. #endif
  76.  
  77. #include "FWARDyna.h"
  78.  
  79. // ----- OpenDoc Includes --------------
  80. #ifndef SOM_Module_OpenDoc_StdProps_defined
  81. #include <StdProps.xh>        // kODPropContents
  82. #endif
  83.  
  84.  
  85. //==============================================================================
  86. const ODValueType CDataSavePart::kPartKind = kDataSaveKind;
  87. const ODValueType CDataSavePart::kPartUserName = kDataSaveEditorUserString;
  88.  
  89. #define kMainPresentation    "Apple:Presentation:DataSave"
  90.  
  91. #ifdef FW_BUILD_MAC
  92. #pragma segment DataSave
  93. #endif
  94.  
  95. //==============================================================================
  96. CDataSavePart::CDataSavePart(ODPart* odPart)
  97.   :    DU_CListPart(odPart, kPartKind, kPartUserName, FW_gInstance, kPartIconID),
  98.     fPresentation(NULL)
  99. {
  100. }
  101.  
  102. //--------------------------------------------------------------------------------
  103. void 
  104. CDataSavePart::Initialize(Environment* ev)    // Override
  105. {
  106.     DU_CListPart::Initialize(ev);
  107.     const FW_Boolean kDefaultPresentation = TRUE;
  108.     fPresentation = this->RegisterPresentation(ev, 
  109.                                 kMainPresentation, 
  110.                                 kDefaultPresentation, 
  111.                                 new DU_CListSelection(ev, this));
  112.     this->MyInitMenus(ev);
  113.  
  114.     // need this for parts that externalize data
  115.     FW_InitializeArchiving(FW_gInstance);
  116. }
  117.  
  118. //--------------------------------------------------------------------------------
  119. CDataSavePart::~CDataSavePart()
  120. {
  121. }
  122.  
  123. //--------------------------------------------------------------------------------
  124. void 
  125. CDataSavePart::MyInitMenus(Environment* ev)
  126. {
  127.     FW_CSharedLibraryResourceFile resFile;    
  128.     FW_CPullDownMenu* pizzaMenu = new FW_CPullDownMenu(ev, resFile, kMenuStringsResID, 
  129.                                                         kPizzaMenuStringID);
  130.     pizzaMenu->AppendTextItem(ev, resFile, kMenuStringsResID, 
  131.                                     kItemOneStringID, cSelectPizzaCmd, '1');
  132.     pizzaMenu->AppendSeparator(ev);
  133.     pizzaMenu->AppendTextItem(ev, resFile, kMenuStringsResID, 
  134.                                     kItemTwoStringID, cMakePizzaCmd, '2');
  135.     this->GetMenuBar(ev)->AdoptMenuLast(ev, pizzaMenu);
  136. }
  137.  
  138. //--------------------------------------------------------------------------------
  139. FW_CFrame* 
  140. CDataSavePart::NewFrame(Environment* ev, ODFrame* odFrame,
  141.                         FW_CPresentation* presentation, FW_Boolean fromStorage)    // Override
  142. {
  143.     FW_UNUSED(presentation);
  144.     FW_UNUSED(fromStorage);
  145.     return new CDataSaveFrame(ev, odFrame, presentation, this);
  146. }
  147.  
  148. //--------------------------------------------------------------------------------
  149. void 
  150. CDataSavePart::MyInvalidatePresentation(Environment* ev, FW_CRect& invalidRect)
  151. {
  152.     fPresentation->Invalidate(ev, invalidRect);
  153. }
  154.  
  155. //--------------------------------------------------------------------------------
  156. void 
  157. CDataSavePart::MyAddPizza(Environment* ev, CPizza* pizza)
  158. {
  159.     this->AddItem(ev, pizza);
  160.     this->MyInvalidatePresentation(ev, pizza->GetBounds() );    
  161. }
  162.  
  163. //--------------------------------------------------------------------------------
  164. void 
  165. CDataSavePart::MyRemovePizza(Environment* ev, CPizza* pizza)
  166. {
  167.     this->RemoveItem(ev, pizza);
  168.     this->MyInvalidatePresentation(ev, pizza->GetBounds() );    
  169.     delete pizza;
  170. }
  171.